home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / programacao / visual / perl.exe / {app} / Webroot / cgi-bin / side_by_side.pl < prev    next >
Encoding:
Perl Script  |  2003-01-11  |  1.6 KB  |  60 lines

  1. #!perl
  2.  
  3. use CGI qw/:standard :netscape/;
  4.  
  5. print header;
  6.  
  7. $frame_name = path_info();
  8. $frame_name =~ s!^/!!;
  9.  
  10. # If no path information is provided, then we create
  11. # a side-by-side frame set
  12. if (!$frame_name) {
  13.     print_frameset();
  14.     exit 0;
  15. }
  16.  
  17. # If we get here, then we either create the query form
  18. # or we create the response.
  19. print start_html();
  20. print_query()    if $frame_name eq 'left';
  21. print_response() if $frame_name eq 'right';
  22. print end_html();
  23.  
  24. # Create the frameset
  25. sub print_frameset {
  26.     my $script = url();
  27.     print title('Side by Side'),
  28.     frameset({-cols=>'50%,50%'},
  29.              frame({-name=>'left',-src=>"$script/left"}),
  30.              frame({-name=>'right',-src=>"$script/right"})
  31.              );
  32.     exit 0;
  33. }
  34.  
  35. sub print_query {
  36.     my $script = url();
  37.     print h1("Frameset Query"),
  38.        start_form(-action=>"$script/right",
  39.                   -target=>"right"),
  40.        "What's your name? ",textfield('name'),p(),
  41.        "What's the combination?",p(),
  42.        checkbox_group(-name=>'words',
  43.                       -values=>['eenie','meenie','minie','moe']),p(),
  44.        "What's your favorite color? ",
  45.        popup_menu(-name=>'color',
  46.                 -values=>['red','green','blue','chartreuse']),
  47.        p(),submit,
  48.        end_form;
  49. }
  50.  
  51.  sub print_response {
  52.    print h1("Frameset Result");
  53.    unless (param) {
  54.        print b("No query submitted yet.");
  55.        return;
  56.    }
  57.    print "Your name is ",em(param(name)),p(),
  58.    "The keywords are: ",em(join(", ",param('words'))),p(),
  59.    "Your favorite color is ",em(param('color'));
  60. }